/*#include  <msp430x14x.h>  */
#include <io430x16x.h>

#include "unet.h"

#define ADCDeltaOn       12                 // ~2 Deg C delta

static unsigned int FirstADCVal;            // holds 1st ADC result




//void get_temperate(void);
__interrupt void ADC12ISR(void);



void get_temperate(void)
{
  //WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog
  P2OUT = 0x00;                             // Clear P2
  P2DIR = 0x01;                             // P2.0 as output
  ADC12CTL1 = SHS_3 + SHP + CONSEQ_2;       // TA trig., rpt conv.//TIMER_B
  ADC12MCTL0 = SREF_1 + INCH_10;            // Channel A10, Vref+  //INCH_10:internal temperature senser
  ADC12IE = 0x01;                           // Enable ADC12IFG.0
  ADC12CTL0 = SHT0_8 + REF2_5V + REFON + ADC12ON + ENC; // Config ADC12
  TBCCTL1 = OUTMOD_4;                       // Toggle on EQU1 (TAR = 0)
  TBCTL = TBSSEL_2 + MC_2;                  // SMCLK, cont-mode
  while (!(0x01 & ADC12IFG));               // First conversion?
  hal
  FirstADCVal = ADC12MEM0;                  // Read out 1st ADC value
  //_BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
}

#pragma vector=ADC_VECTOR
__interrupt void ADC12ISR (void)
{
  
  if (ADC12MEM0 <= FirstADCVal + ADCDeltaOn)
  {
    unsigned char temperate=ADC12MEM0;
     putdata(1, &temperate);
  }
    //   P1OUT &= ~0x01;                       // LED off
 // else P1OUT |= 0x01;                       // LED on
}
